/**
**************************************************************************************
*Founder Effect                                                                      *
*Copyright (C) 2006-2007, 5d Studios (www.5d-Studios.com)                            *
*                                                                                    *
*This library is free software; you can redistribute it and/or                       *
*modify it under the terms of the GNU Lesser General Public                          *
*License as published by the Free Software Foundation; either                        *
*version 2.1 of the License, or (at your option) any later version.                  *
*                                                                                    *
*This library is distributed in the hope that it will be useful,                     *
*but WITHOUT ANY WARRANTY; without even the implied warranty of                      *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                   *
*Lesser General Public License for more details.                                     *
*                                                                                    *
*You should have received a copy of the GNU Lesser General Public                    *
*License along with this library; if not, write to the Free Software                 *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA      *
**************************************************************************************
*/
#pragma once

#include <string>
//#include <vector>
//#include <map>

#include "../shared/MFile.h"
#include "../shared/EntDict.h"
#include "Typedefs.h"

/*----------------------------------------
    Constants
-----------------------------------------*/
const int LAYER_ONE =1;
const int LAYER_TWO =2;

class IEntity;
class Scene;
class Tile;

/**
==========================
Imports a .MAP file, and parses it out

File tree --  [name].MAP  -- zip file containing the following
				|
				+-[name].DFN -- defines tile sets
				|
				+-[name].LY1 -- background tiles
				|
				+-[name].LY2 -- collidable tiles/ with triggers
				|
				+-[name].EVT -- defines triggers for tiles
				|
				+-[name].ENTS -- defines entities 
==========================
*/
class QuestImporter
{
public:
    QuestImporter() {};
	
	/** Create the a scene from a .MAP file */
	Scene* CreateScene(const std::string &file);

	/** Get the current version of .MAP setup */
	std::string GetVersion() { return m_version; };

private:
	/** Parse the .DFN file */
    void ParseDefine();

    /** Parse .LY1 and .LY2 files -- The map layer */
    void ParseLayers(int layer, type_Layer &layers, Scene* scene );

    /** Parse .EVT file -- The events on each tile */
    void ParseEvents(Scene* scene);

    /** Parse .ENTS file -- The Entities on a map */
    void ParseEntities();
    /** Parses a given layer */
    void Parse(type_Layer &layer, MFile &file, Scene* scene );
    
    /** Release resources */
    void Release();
    // name of the map
    std::string m_name;

	// Version
	std::string m_version;

	// Tiles to choose from
    typedef std::map< std::string, Tile*> type_Tiles;
	type_Tiles m_tiles;

    // Entities to choose from
    typedef std::map< std::string, IEntity*> type_EntDict;
    type_EntDict m_entities;

public:
    virtual ~QuestImporter(void);
};
